<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>

  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content report">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/report">报表</a></li>
          <li class="active">专项课平均上课率报表</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
          
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>报表&nbsp;-&nbsp;线下1V1平均上课率报表</span></h2>
              <div class="pull-right">
                <c:choose>
                  <c:when test="${not empty currentPrincipal.site}">
                    <span class="current-branchCode">${currentPrincipal.site.name}</span>
                  </c:when>
                  <c:otherwise>
                    <select name="site">
                      <option value="">所有门店</option>
                      <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                        <option value="${site.id}" ${site.id == selectSite.id ? 'selected' : ''}>${site.name}</option>
                      </c:forEach>
                    </select>
                  </c:otherwise>
                </c:choose>
              </div>
            </div>
            
          </div>
          
          <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
            <fmt:formatDate value="${currentDate}" pattern="yyyy-MM-dd" var="day" />
            <ul class="nav nav-pills x-breadcrumb-nav">
              <li class="pull-left ${period eq 'day' ? 'active' : ''}"><a href="${ctx.host}/special-hour-reports?site=${selectSite.id}&date=${day}&period=day">日</a></li>
              <li class="pull-left ${period eq 'week' ? 'active' : ''}"><a href="${ctx.host}/special-hour-reports?site=${selectSite.id}&date=${day}&period=week">周</a></li>
              <li class="pull-left ${period eq 'month' ? 'active' : ''}"><a href="${ctx.host}/special-hour-reports?site=${selectSite.id}&date=${day}&period=month">月</a></li>
              <div class="pull-right" style="margin-left:15px;">
                <input type="text" class="form-control date" name="date" value="${day}" data-validate = "required" placeholder="请选择日期" readOnly/>
              </div>
              <a href="${ctx.host}/special-hour-reports/export-view" data-target="#report-export" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default pull-right">导出</a>
            </ul>
          </div>
          
          <div class="tab-content">
            <div class="tab-pane fade active in"style="min-height: 100px;">
               <h2 class="title">
                 <c:choose>
                   <c:when test="${period == 'day'}">
                     <p class="form-control-statis pull-right">日期：${day}</p>
                   </c:when>
                   <c:otherwise>
                     <p class="form-control-statis pull-right">日期：${startDate}&nbsp;&nbsp;-&nbsp;&nbsp;${endDate}</p>
                   </c:otherwise>
                 </c:choose>
               </h2>
              
              <div style="margin: 0 15px;">
                <table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
                  <thead>
                    <tr>
                      <th>门店</th>
                      <th>学员到店销课次数</th>
                    </tr>
                  </thead>
                  <tbody>
                    <c:forEach var="currentSite" items="${empty selectSite ? persist.getSites(currentPrincipal.id) : selectSite.arraySite}">
                      <tr>
                        <td>${currentSite.name}</td>
                        <td>${empty siteHourList[currentSite.name] ? 0 : siteHourList[currentSite.name].hour}</td>
                      </tr>
                    </c:forEach>
                    <c:if test="${empty selectSite}">
                      <tr>
                        <td>全部门店</td>
                        <td>${empty hour ? 0 : hour}</td>
                      </tr>
                    </c:if>
                  </tbody>
                </table>
              </div>
              
              <h2 class="title clearfix">
                <i class="glyphicon glyphicon-triangle-right" style="color: #FF8100;" title=""></i>&nbsp;&nbsp;<span>详细数据</span>
              </h2>
              
              <div style="margin: 0 15px;">
                  <table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
                    <thead>
                      <tr>
                        <th>门店</th>
                        <th>课程</th>
                        <th>学员姓名</th>
                        <th>学员手机号</th>
                        <th>教练</th>
                        <th>搜索时间范围内上课累计次数</th>
                      </tr>
                    </thead>
                    <tbody>
                      <c:forEach var="stat" items="${statList}">
                        <tr>
                          <td>${stat.site}</td>
                          <td>${stat.course}</td>
                          <td>${stat.student}</td>
                          <td>${stat.mobile}</td>
                          <td>${stat.coach}</td>
                          <td>${stat.hour}</td>
                          <!-- <td><a href="${ctx.host}/${courseRound.courseType.alias}-rounds/${courseRound.id}">详情</a></td> -->
                        </tr>
                      </c:forEach>
                    </tbody>
                  </table>
                  
                </div>
            </div>
          </div>
          
        </div>

      </div>

    </div>

  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/report/individual-hour-report.js">
    <script type="text/javascript">
      require(['page/report/individual-hour-report'], function(page) {
        page.init({
          "date": '${day}',
          "site": '${selectSite.id}',
          "period": '${period}',
          "today": '${today}'
        })
      })
    </script>
  </d:resource>
  
</body>
</html>